package com.ksd.web.controller.tool;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class FileUtils {
    public static List<File> getAllFiles(String directoryPath) {
        List<File> fileList = new ArrayList<>();
        File directory = new File(directoryPath);
        if (directory.exists() && directory.isDirectory()) {
            File[] files = directory.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (file.isDirectory()) {
                        // 递归获取子目录下的文件
                        fileList.addAll(getAllFiles(file.getAbsolutePath()));
                    } else {
                        fileList.add(file);
                    }
                }
            }
        }
        return fileList;
    }

}
